package org.zoomdev.zoom.dao.impl;

import org.apache.commons.lang3.StringUtils;
import org.zoomdev.zoom.dao.DaoException;
import org.zoomdev.zoom.dao.annotations.Table;

public final class TableNameUtils {

    public static String getTableName(Class<?> type) {
        Table table = type.getAnnotation(Table.class);
        if (table == null) {
            throw new DaoException("找不到" + type + "的Table标注，不能绑定实体");
        }
        String tableName = table.value();
        if (StringUtils.isEmpty(tableName)) {
            throw new DaoException("在标注中必须指定表名称" + table);
        }
        return tableName;
    }
}
